package fractal;

import java.util.ArrayList;
import java.util.List;

import entity.Position;

import kingdom.City;
import kingdom.EchelleValue;
import kingdom.Kingdom;

public class GenerateurKingdom
{
	List<Kingdom> listKingdom = new ArrayList<Kingdom>();

	public void createKingdom( TerrainMap pTerrain )
	{
		Kingdom kingdom = createKingdom(pTerrain, 1, 10, 10);
		kingdom.getEchelleTemp().addEchelleValue(new EchelleValue(0, 40, 10));
		kingdom.getEchelleTemp().addEchelleValue(new EchelleValue(40, 60, 10));
		kingdom.getEchelleTemp().addEchelleValue(new EchelleValue(60, 65, 25));
		kingdom.getEchelleTemp().addEchelleValue(new EchelleValue(65, 90, 25));
		kingdom.getEchelleTemp().addEchelleValue(new EchelleValue(90, 101, 0));
		listKingdom.add(kingdom);
		kingdom = createKingdom(pTerrain, 2, 10, 100);
		kingdom.getEchelleTemp().addEchelleValue(new EchelleValue(0, 40, 20));
		kingdom.getEchelleTemp().addEchelleValue(new EchelleValue(40, 60, 40));
		kingdom.getEchelleTemp().addEchelleValue(new EchelleValue(60, 65, 40));
		kingdom.getEchelleTemp().addEchelleValue(new EchelleValue(65, 90, 0));
		kingdom.getEchelleTemp().addEchelleValue(new EchelleValue(90, 101, 0));
		listKingdom.add(kingdom);
		kingdom = createKingdom(pTerrain, 3, 150, 10);
		kingdom.getEchelleTemp().addEchelleValue(new EchelleValue(0, 40, 0));
		kingdom.getEchelleTemp().addEchelleValue(new EchelleValue(40, 60, 5));
		kingdom.getEchelleTemp().addEchelleValue(new EchelleValue(60, 65, 60));
		kingdom.getEchelleTemp().addEchelleValue(new EchelleValue(65, 90, 40));
		kingdom.getEchelleTemp().addEchelleValue(new EchelleValue(90, 101, 0));
		listKingdom.add(kingdom);
	}

	public void aggrandir( int pNbYears )
	{
		for (int i = 0; i < pNbYears; i++)
		{
			for (Kingdom kingdom : listKingdom)
			{
				kingdom.grandir();
			}

		}
	}

	protected Kingdom createKingdom( TerrainMap pTerrain , int pNb , int x ,
			int y )
	{
		Kingdom result = new Kingdom(pTerrain, pNb);
		result.getTerrainList().add(new Position(x, y));
		result.getCityList().add(new City());
		pTerrain.getMap()[x][y].setCity(true);
		pTerrain.getMap()[x][y].setIndiceEmpire(100);
		return result;
	}
}
